var waybill_history_detail = {
    init: function() {
        var that = this;

        that.initCloseBill();
        // todo显示窗口
        // $('.J_btn-cancel').click();
    },
    initCloseBill: function() {
        $(document).on('click', '.J_btn-cancel', function() {
            $('#bill-detail-model').modal();
        })
    },
    renderDetail: function(id, callback) {
        var self = this;
        var compiled = _.template($("#waybill_history_detail_part").html());
        $.ajax({
            url: COMMONURL + "api/BidLoad/GetBidLoadInfo?token=" + $.cookie('token'),
            type: "post",
            data: {
                load_id: id
            },
            dataType: "json"
        }).done(function(data) {
            if (!data) return;
            if (!data.mod) return;
            $(".bill-detail table").html(compiled(data.mod));
            // 填写标书编号和标书状态
            $('.bill-no .value').html(data.mod.bid_no);
            var status = self.billStatusFilter(data.mod.state);
            $('.bill-status .value').html(status);
            callback && callback();
        })
    },
    billStatusFilter: function(value) {
        var map =  {
            '1': '等待开始',
            '10': '竞标中',
            '20': '竞标结束',
            '30': '选标中',
            '50': '竞标失败',
            '80': '竞标成功',
            '90': '受理完成',
            '95': '拒标',
            '100': '接单等待取货',
            '105': '未取货',
            '110': '取货成功',
            '115': '到货确认',
            '120': '成功接收回单',
            '140': '运单关闭',
            '150': '结款',
            '-1': '删除'
        }
        return map[value];
    }
}

waybill_history_detail.init();
